<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@include file="/WEB-INF/base/commRoot.jsp"%>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="format-detection" content="telephone=no" />
<script type="text/javascript" src="/js/jquery-1.11.1.min.js"></script>
<link type="image/x-icon" href="/images/pay.ico"  rel="icon"></link>
<title>惠信钱包App下载</title>
	<style type="text/css">
		html {font-size: 62.5%;}
		html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,dl,dt,dd,ol,nav ul,nav li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;}
		body {font-size:14px; font-family:SimHei; color:#555;}
		img{ display:block; max-width:100%;}
		.wrap{ background:#fff;}
		.logo_ad{ width:284px; height:154px; margin:34px auto 0;}
		.dload_iphone{ width:280px; height:70px;margin:0 auto 16px;}
		.dload_android{ width:280px; height:70px;margin:0 auto;}
		.guide_pay{ width:393px; height:522px; margin:0 auto 16px;}
		.app_pic{display: none;height: 303px;position: absolute;right: 0;top: 0;width: 100%;z-index: 99;}
		#zb {background-color: #333;display: none;height: 100%;left: 0;opacity: 0.5;position: fixed;top: 0;width: 100%;z-index: 1;}
	</style>
</head>

<body>

<!--顶部-->
<div class="wrap">
	<img src="/images/logo_ad.png" width="323" height="155" alt="惠信钱包logo" class="logo_ad" />
    <div style=" margin-bottom: 30px;">
        <a href="javascript:void(0)" id="iosDown"><img src="/images/download_iphone.png" width="280" height="70" class="dload_iphone" /></a>	
        <a href="javascript:void(0)" id="androidDown"><img src="/images/download_android.png" width="280" height="70" class="dload_android" /></a>	
    </div>
    <img src="/images/guide_pay.png" width="391" height="519" class="guide_pay" />
</div>
<div id="showmsg" class="app_pic"><img src="/images/pic.png" width="100%" /></div>
<div id="zb"></div>

<script type="text/javascript">
    var hkdAppUrl_Ios = appDownPath(2);//IOS APP下载地址
    var hkdAppUrl_Android = appDownPath(1);//Android APP下载地址
    var andriodDown = document.getElementById('androidDown');
    var iosDown = document.getElementById('iosDown');
    var ua = navigator.userAgent.toLowerCase();
    var showmsg = document.getElementById("showmsg"),
    zb = document.getElementById("zb");
    
    /* if (/iphone|ipad|ipod/.test(ua)) {
        iosDown.href = hkdAppUrl_Ios;
        //请在手机上使用该浏览器打开本页面，即可安装
    }else{
    	andriodDown.href = hkdAppUrl_Android;
    } */
    
    //平台、设备和操作系统     
    var system = { win : false, mac : false, xll : false };    
    //检测平台     
    var p = navigator.platform;    
    system.win = p.indexOf("Win") == 0;    
    system.mac = p.indexOf("Mac") == 0;    
    system.x11 = (p == "X11") || (p.indexOf("Linux") == 0); 
    
    if(!(system.win||system.mac||system.xll)){//移动端
	    if (/iphone|ipad|ipod/.test(ua)) {
	    	if(hkdAppUrl_Ios == null || hkdAppUrl_Ios == ""){
	    		alert("无更新版本");
	    	}else{
		    	location.href = hkdAppUrl_Ios;
	    	}
		}else if(/windows phone|blackberry/.test(ua)){
			alert("抱歉，此应用暂不支持您的系统");
		}else{
    		if(hkdAppUrl_Android == null || hkdAppUrl_Android == ""){
		    	alert("无更新版本");
	    	}else{
				if(!is_weixin()){
				    window.location.href = hkdAppUrl_Android;
		    	}
	    	}
		}
    }
    
    $(document).ready(function() {
		$("#iosDown").click(function(){
			if(hkdAppUrl_Ios == null || hkdAppUrl_Ios == ""){
	    		alert("无更新版本");
	    	}else{
				if(system.win||system.mac||system.xll){
					iosDown.href = hkdAppUrl_Ios;
				}else{//移动端
					if (/iphone|ipad|ipod/.test(ua)) {
				        iosDown.href = hkdAppUrl_Ios;
					}else{
				    	alert("请在ios设备上使用浏览器打开本页面");
				    }
				}
	    	}
		});
		
		$("#androidDown").click(function(){
			if(hkdAppUrl_Android == null || hkdAppUrl_Android == ""){
	    		alert("无更新版本");
	    	}else{
				if(system.win||system.mac||system.xll){
					andriodDown.href = hkdAppUrl_Android;
				}else{//移动端
					if(/android/.test(ua)){
				    	if(is_weixin()){
				    		andriodDown.href = 'javascript:show();';
					    }else{
					    	andriodDown.href = hkdAppUrl_Android;
					    }
				    }else{
				    	alert("请在Android设备上使用浏览器打开本页面，即可安装");
				    }
				}
	    	}
		});
	});
    
    
    /**
	 * 同步请求下载地址
	 */
	function appDownPath(downType){
		var addr;
		if(downType == null) return;
		<%-- $.ajaxSetup({async: false});//改为同步方法
		$.post(<%=basePath%>+"https://app.pay.365sji.com:6443/hxqbAppAPI/hxqbAppApiRest/appInfoRestService/downApp",{appType:downType},function(data){
			if(data.flag == 1){
				addr = data.rs.downloadURL;
	     	}
		}); --%>
		
		$.ajax({
			type : "POST",
			async: false,
			url : "static/staticAction_downApp.action",
			data : {appType:downType},
			dataType : 'json',
			success : function(data) {
				if(data[0].flag == 1){
					addr = data[0].rs.downloadURL;
		     	}
			}
		});
		
		return addr;
	}

    /* var showmsg = document.getElementById("showmsg"),
    zb = document.getElementById("zb"); */
    
    function is_weixin() {
        var ua = navigator.userAgent.toLowerCase();
        return ua.match(/MicroMessenger/i) == "micromessenger";
    }
    
    function show() {
        showmsg.style.display = 'block';
        zb.style.display = 'block';
    }
    
    zb.onclick = showmsg.onclick = function() {
        showmsg.style.display = 'none';
        zb.style.display = 'none';
    }
    
</script>
</body>
</html>
